import { EChartsOption } from 'echarts'

export const pieStageOptions: EChartsOption = {
  tooltip: {
    trigger: 'item',
    formatter: '{a} <br/>{b}: {c} ({d}%)'
  },
  grid: {
    containLabel: true // 确保标签不会被裁剪
  },
  legend: {
    top: 15,
    left: 'center',
    width: '430px',
    itemWidth: 20,
    icon: 'circle',
  },
  series: [
    {
      name: '项目阶段',
      type: 'pie',
      radius: '50%',
      center: ['50%', '64%'],
      avoidLabelOverlap: false,
      itemStyle: {
        borderColor: '#fff',
        borderWidth: 0,
        color: function (colors) {
          const colorList = [
            '#5087EC',
            '#68BBC4',
            '#58A55C',
            '#F2BD42',
            '#EE752F',
            '#D95040',
            '#5087EC',
            '#68BBC4',
            '#58A55C',
            '#F2BD42'
          ]
          return colorList[colors.dataIndex]
        }
      },
      data: [
        { value: 0, name: '项目移交' },
        { value: 0, name: '项目定级' },
        { value: 0, name: '团队组建' },
        { value: 0, name: '开工填报' },
        { value: 0, name: '实施进度' },
        { value: 0, name: '试运行' },
        { value: 0, name: '项目交付' },
        { value: 0, name: '项目审计' },
        { value: 0, name: '后评估' },
        { value: 0, name: '已结束' }
      ],
      emphasis: {
        label: {
          formatter: '{b}:{c}',
          show: true,
          fontSize: 13,
          fontWeight: 'bold'
        },
        itemStyle: {
          shadowBlur: 10,
          shadowOffsetX: 0,
          shadowColor: 'rgba(0, 0, 0, 0.5)'
        }
      }
    }
  ]
}

export const pieTypeOptions: EChartsOption = {
  tooltip: {
    trigger: 'item',
    formatter: '{a} <br/>{b}: {c} ({d}%)'
  },
  grid: {
    top: 10,
    containLabel: true // 确保标签不会被裁剪
  },
  legend: {
    top: '5%',
    left: 'center',
    icon: 'circle'
  },
  series: [
    {
      name: '项目类型',
      type: 'pie',
      radius: '50%',
      center: ['50%', '53%'],
      avoidLabelOverlap: false,
      itemStyle: {
        borderColor: '#fff',
        borderWidth: 0,
        color: function (colors) {
          const colorList = ['#5087EC', '#68BBC4', '#58A55C', '#F2BD42']
          return colorList[colors.dataIndex]
        }
      },
      data: [
        { value: 0, name: '纯建设' },
        { value: 0, name: '纯运维' },
        { value: 0, name: '建设+运维' }
      ],
      emphasis: {
        label: {
          formatter: '{b}:{c}',
          show: true,
          fontSize: 13,
          fontWeight: 'bold'
        },
        itemStyle: {
          shadowBlur: 10,
          shadowOffsetX: 0,
          shadowColor: 'rgba(0, 0, 0, 0.5)'
        }
      }
    }
  ]
}

export const barTimeOptions: EChartsOption = {
  tooltip: {
    trigger: 'axis',
    axisPointer: {
      type: 'cross',
      crossStyle: {
        color: '#999'
      }
    }
  },
  grid: {
    height: '80%',
    top: 60,
    left: 10,
    right: 10,
    containLabel: true
  },
  legend: {
    top: 10
  },
  xAxis: [
    {
      type: 'category',
      data: ['2020', '2021', '2022', '2023', '2024'],
      show: true
    }
  ],
  yAxis: [
    {
      type: 'value',
      name: '金额',
      axisLabel: {
        formatter: '{value}万'
      },
      show: true,
      scale: true
    }
  ],
  series: [
    {
      name: '合同总额',
      type: 'line',
      smooth: true,
      areaStyle: {
        color: 'rgba(100,149,237, 0.3)'
      },
      tooltip: {
        valueFormatter: function (value) {
          return value + '  万'
        }
      },
      data: [0, 0, 0, 0, 0]
    },
    {
      name: '已结项总额',
      type: 'line',
      smooth: true,
      areaStyle: {
        color: 'rgba(100,149,237, 0.3)'
      },
      tooltip: {
        valueFormatter: function (value) {
          return value + '  万'
        }
      },
      data: [0, 0, 0, 0, 0]
    }
  ]
}